package cn.edu.neusoft.wuguangsheng.market.activity;

import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import java.util.List;

import cn.edu.neusoft.wuguangsheng.market.R;
import cn.edu.neusoft.wuguangsheng.market.adapter.CommentsAdapter;
import cn.edu.neusoft.wuguangsheng.market.bean.UserAllCommentBean;
import cn.edu.neusoft.wuguangsheng.market.listener.ListListener;
import cn.edu.neusoft.wuguangsheng.market.model.UserAllCommentModel;

public class UserAllCommentActivity extends BaseActivity{
    RecyclerView recyclecomment;
    private List<UserAllCommentBean> items;
    ImageView usercmfh;
    Boolean up=false;
    @Override
    void initView() {
        setLayout_file(R.layout.activity_user_all_comment);
        recyclecomment=(RecyclerView)findViewById(R.id.recyclecomment);
        usercmfh=(ImageView)findViewById(R.id.usercmfh);
        LinearLayoutManager linearLayoutManager=new LinearLayoutManager(UserAllCommentActivity.this);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclecomment.setLayoutManager(linearLayoutManager);
        String uid=getid();
        UserAllCommentModel userAllCommentModel=new UserAllCommentModel();
        userAllCommentModel.showUserAllComment(uid,listListener);
    }

    @Override
    void initEvent() {
        usercmfh.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    void initDate() {

    }
ListListener<UserAllCommentBean> listListener=new ListListener<UserAllCommentBean>() {
    @Override
    public void onResponse(List<UserAllCommentBean> list) {
        items=list;
        CommentsAdapter commentsAdapter=new CommentsAdapter(UserAllCommentActivity.this,items,R.layout.commentscard);
        recyclecomment.setAdapter(commentsAdapter);
        recyclecomment.setItemAnimator(new DefaultItemAnimator());
    }

    @Override
    public void onFail(String msg) {

    }
};

    @Override
    public void onPause() {
        super.onPause();
        up=true;

    }

    @Override
    public void onResume() {
        super.onResume();
        if(up){
            initView();
            up=false;
        }
    }
}
